#include "mainwindow.h"
#include "ui_mainwindow.h"

#include "qpdfium.h"
#include "qpdfiumpage.h"

#include <QPushButton>
#include <QFileDialog>
#include <QDebug>

MainWindow::MainWindow(QWidget* parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QPdfium* pdf = new QPdfium();
    connect(ui->pushButton, &QPushButton::clicked, this, [ = ]()
    {
        auto path = QFileDialog::getOpenFileName(this, "pdf", "./");
        if (!path.isEmpty())
        {
            auto status = pdf->loadFile(path);
            qDebug() << "status" << status << pdf->isValid() << pdf->pageCount();
            //            auto page = pdf->page(0);
            //            ui->label->setPixmap(QPixmap::fromImage(page.image()));
        }
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

